home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Over 1,000 Windows 95 Programs
/
Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso
/
1257
/
depot.cp_
/
depot.cp
Wrap
Text File
|
1997-04-18
|
4KB
|
155 lines
/* EasyCODE(C++) V5.1 01.03.1995 08:02:39
Library Management: Stack-Room Lending */
/* EasyCODE O
If=horizontal
LevelNumbers=no
LineNumbers=no
ScreenFont=Arial,,100,9220,-13,0,400,0,0,0,0,0,0,3,2,1,34
PrinterFont=Courier,,100,2,-42,0,400,0,0,0,0,0,0,2,1,2,49
LastLevelId=7 */
/* EasyCODE ( 1
Stack-Room Lending */
#include "libdat.h"
#include <time.h>
/* EasyCODE - */
extern int ClpBrdUsrNo;
extern BOOL ClpBrdUsrLock;
extern int iBookLimit;
extern int iFilUsr;
extern int iMaxLoan;
extern user_item user[];
extern loan_item loan[];
/* EasyCODE - */
void ReadBookData(int&, char *);
BOOL BookBorrowed(int);
void WriteLendingForm(void);
void WriteLendingFile(int, char *);
/* EasyCODE ( 3
Stacks */
/* EasyCODE F */
void Stacks(void)
{
int CallNumber;
char Author[BUFFER_SIZE];
if (!ClpBrdUsrLock)
{
ReadBookData(CallNumber, Author);
while ((user[iFilUsr].NumBooks < iBookLimit) &&
(CallNumber != 0))
{
if (!BookBorrowed(CallNumber))
{
WriteLendingFile(CallNumber, Author);
/* EasyCODE - */
WriteLendingForm();
/* EasyCODE - */
user[iFilUsr].NumBooks+=1;
}
else
{
cout << "Book on loan" << endl;
cin;
/* EasyCODE - */
// Handle waiting list entry
}
if (user[iFilUsr].NumBooks == iBookLimit)
{
cout << "Book limit reached" << endl;
cin;
}
else
{
ReadBookData(CallNumber, Author);
}
}
}
}
/* EasyCODE ) */
/* EasyCODE ( 4
ReadBookData */
/* EasyCODE F */
void ReadBookData(int& CallNumber, char *Author)
{
if (user[iFilUsr].NumBooks < iBookLimit)
{
cout << "\nCall number: ";
cin >> CallNumber;
cout << "Author: ";
cin >> Author;
}
else
{
cout << "User borrowed maximum number of books !";
cin;
}
}
/* EasyCODE ) */
/* EasyCODE ( 5
BookBorrowed */
/* EasyCODE F */
BOOL BookBorrowed(int CallNumber)
{
BOOL bFound = FALSE;
for (int i = 0; (i < iMaxLoan) && !bFound; i++)
{
if (loan[i].CallNo == CallNumber)
{
bFound = TRUE;
}
}
/* EasyCODE < */
return(bFound);
/* EasyCODE > */
}
/* EasyCODE ) */
/* EasyCODE ( 6
WriteLendingForm */
/* EasyCODE F */
void WriteLendingForm(void)
{
cout << "\n\n\n\nRequest book from stacks !";
cout << "\n\n\n\n LENDING FORM: ";
cout << "\n\nCall number: " << loan[iMaxLoan-1].CallNo;
cout << "\nUser number: " << loan[iMaxLoan-1].UserNo;
cout << "\nDate of borrowing: " << loan[iMaxLoan-1].LendingDate;
cout << "\nDate of return: " << loan[iMaxLoan-1].Return;
cout << "\nAuthors: " << loan[iMaxLoan-1].Author1 << endl;
cin;
}
/* EasyCODE ) */
/* EasyCODE ( 7
WriteLendingFile */
/* EasyCODE F */
void WriteLendingFile(int CallNumber, char *Author)
{
time_t lLendingDate;
time_t lReturnDate;
/* EasyCODE - */
time(&lLendingDate);
// 4 weeks --> 2419200 seconds
lReturnDate = lLendingDate + 2419200;
/* EasyCODE - */
iMaxLoan++;
loan[iMaxLoan-1].CallNo = CallNumber;
loan[iMaxLoan-1].UserNo = ClpBrdUsrNo;
strcpy (loan[iMaxLoan-1].LendingDate, ctime(&lLendingDate));
strcpy (loan[iMaxLoan-1].Return, ctime(&lReturnDate));
strcpy (loan[iMaxLoan-1].Author1, Author);
}
/* EasyCODE ) */
/* EasyCODE ) */